unit Frame_Settings_General;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls, ComCtrls, Registry;

type
  TFrame_Set_General = class(TFrame)
    GroupBox4: TGroupBox;
    Button5: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    TrackBar1: TTrackBar;
    procedure Button5Click(Sender: TObject);
  private
    procedure AssociateFileType(FileType: string);
  end;

implementation

{$R *.dfm}

procedure TFrame_Set_General.AssociateFileType(FileType: string);
var
  Reg: TRegistry;
  tmpvalue: string;
begin
  Reg := TRegistry.Create;
  try
    with Reg do
      begin
        RootKey := HKEY_CLASSES_ROOT;
        if KeyExists('.' + FileType) = true then
          OpenKey('.' + FileType, true)
        else
          begin
            CreateKey('.' + FileType);
            OpenKey('.' + FileType, true);
            WriteString('', 'SimplyPlay.' + FileType);
          end;

        tmpvalue := ReadString('');
        CloseKey;

        if KeyExists(tmpvalue) = true then
          begin
            OpenKey(tmpvalue, true);
            WriteString('', 'SimplyPlay ' + AnsiUpperCase(FileType) + ' file');
            if KeyExists('DefaultIcon') = true then
              begin
                OpenKey('DefaultIcon', true);
                WriteString('', Application.ExeName + ',1');
                CloseKey;
              end
            else
              begin
                CreateKey('DefaultIcon');
                OpenKey('DefaultIcon', true);
                WriteString('', Application.ExeName + ',1');
                CloseKey;
              end;
            CloseKey;
          end;
      end;
  finally
    Reg.Free;
  end;
end;

procedure TFrame_Set_General.Button5Click(Sender: TObject);
begin
  AssociateFileType('pls');
end;

end.
